package com.woniuxy.oldmanapi.controller;

import com.github.pagehelper.PageInfo;
import com.woniuxy.oldmanapi.entity.Contracttype;
import com.woniuxy.oldmanapi.service.ContractService;
import com.woniuxy.oldmanapi.service.ContractTypeService;
import com.woniuxy.oldmanapi.vo.ResponseResult;
import com.woniuxy.oldmanapi.yvo.ContractVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ContractTypeController {
    @Autowired
    ContractTypeService contractTypeService;
    /**
     * 初始化查询所有类型
     * @return
     */
    @GetMapping("/contractType/list")
    public ResponseResult<List<Contracttype>> initSelectAllByCons() {
        ResponseResult<List<Contracttype>> result = new ResponseResult<>();
        try {
            List<Contracttype> pageInfo = contractTypeService.initSelectAllByCons();
            if (pageInfo == null) {
                result.setCode(204);
                result.setMsg("无满足条件对象");
            } else {
                result.setCode(200);
                result.setMsg("查询成功");
                result.setData(pageInfo);
            }
        } catch (Exception e) {
            result.setCode(201);
            result.setMsg("系统繁忙,请稍后再试");
        }
        return result;
    }
}
